import request from '../../utils/request';
const lawyer = {
  state: {

  },

  getters: {

  },

  mutations: {

  },

  actions: {
    /**
     * 获取律师列表
     * @payload{
     *  pageNum  string 
     *  mobileNo string 
     *  userId string 
     *  name     string 
     *  startDay string 
     *  endDay   string 
     * }
     * */
    GET_LAWYER_LIST({ commit }, payload) {
      return new Promise((resolve, reject) => {
        request.get('/lawyer/list.htm', {
          params: payload
        }).then(res => {
          console.log('commit::', commit);
          resolve(res);
        }).catch(err => {
          console.error('err::::', err);
          reject(err);
        })
      });
    },

    /***
     * 律师管理-详情
     * 根据律师id获取律师信息
     * @params payload{
     *  id string
     * }
     * */
    GET_LAWYER_BY_ID({ commit }, payload) {
      return new Promise((resolve, reject) => {
        request.post('/lawyer/detail.htm', payload).then(res => {
          console.log('commit::', commit);
          resolve(res);
        }).catch(err => {
          console.error('err::::', err);
          reject(err);
        })
      });
    },

    /**
     * 律师管理-编辑/禁用/启用
     * @params payload{
     *  name string 	律师姓名
     *  idCardNo string 身份证
     *  gender string 性别， male：男性，female：女性
     *  email string 
     *  wechatId string 微信
     *  licenseNo string 执照号
     *  province string 
     *  city string 
     *  skillFirst string 技能1
     *  skillSecond string 
     *  skillThird string 
     *  address string 
     *  lawfirmName string 	律师所名字
     *  idCardFront string 身份证正面url
     *  idCardBack string 身份证反面url
     *  certificatePic string 资质照片url
     *  userId string 律师id
     *  state string  状态， normal("正常"), frozen("冻结"),
     *  recommond string  1 （推荐） 0 (不推荐)
     * }
     * */
    UPDATE_LAWYER({ commit }, payload) {
      return new Promise((resolve, reject) => {
        request.post('/lawyer/edit.htm', payload).then(res => {
          console.log('commit::', commit);
          resolve(res);
        }).catch(err => {
          console.error('err::::', err);
          reject(err);
        })
      });
    },

    /**
     * 律师审核-审核
     * @params payload{
     *  id string 列表里的id
     *  state string 	审核 state : passed 通过,refused: 拒绝 
     *  refusedReason string 拒绝原因
     * }
    */
    LAWYER_AUDIT({ commit }, payload) {
      return new Promise((resolve, reject) => {
        request.post('/lawyer/audit.htm', payload).then(res => {
          console.log('commit::', commit);
          resolve(res);
        }).catch(err => {
          console.error('err::::', err);
          reject(err);
        })
      });
    },

    /**
     * 律师审核-详情
     * @params payload{
     *  id string 列表里的id
     * }
    */
    GET_AUDIT_DETAIL({ commit }, payload) {
      return new Promise((resolve, reject) => {
        request.post('/lawyer/applyDetail.htm', payload).then(res => {
          console.log('commit::', commit);
          resolve(res);
        }).catch(err => {
          console.error('err::::', err);
          reject(err);
        })
      });
    },

    /**
     * 获取律师审核列表
     * @payload{
     *  pageNum  string 
     *  state    string   applied(已申请),refused(已拒绝),passed(已通过),notapply
     *  mobileNo string 
     *  userId string 
     *  name     string 
     *  startDay string 
     *  endDay   string 
     * }
     * */
    GET_LAWYER_AUDIT_LIST({ commit }, payload) {
      return new Promise((resolve, reject) => {
        request.get('/lawyer/applyList.htm', {
          params: payload
        }).then(res => {
          console.log('commit::', commit);
          resolve(res);
        }).catch(err => {
          console.error('err::::', err);
          reject(err);
        })
      });
    },

    /**
     * 招标管理-指派律师
     * @payload{
     *  caseId  string 
     *  lawyerId    string  
     * }
     * */
    ASSIGN_LAWYER({ commit }, payload) {
      return new Promise((resolve, reject) => {
        request.post('/case/assign.htm', payload).then(res => {
          console.log('commit::', commit);
          resolve(res);
        }).catch(err => {
          console.error('err::::', err);
          reject(err);
        })
      });
    }

  }
}

export default lawyer